home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: These string questions just won't go away......
  5. Date: Tue, 02 Jan 96 00:33:33 GMT
  6. Organization: none
  7. Message-ID: <820542813snz@genesis.demon.co.uk>
  8. References: <4c67g1$k88@news1.usa.pipeline.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4c67g1$k88@news1.usa.pipeline.com>
  15.            grantp@usa.pipeline.com(Pete) "Pete" writes:
  16.  
  17. >On Dec 30, 1995 02:21:50 in article <These string questions just won't go
  18. >away......>, 'aldo@tribeca.ios.com (Aldo Di Domenico)' wrote: 
  19. >>void 
  20. >>f(char *input) 
  21. >>{ 
  22. >>input--; 
  23. >>printf(*input); 
  24. >This should cause a fault.
  25.  
  26. It results in undefined behaviour. Generating a fault is one possibility but
  27. there are an almost limitless supply of others. printf is a variadic function
  28. which means it is illegal to call it without a prototype in scope (e.g.
  29. by including stdio.h). If there was a prototype in scope the compiler would
  30. have generated a diagnostic for this.
  31.  
  32. > What you probably want to do is omit 
  33. >the dereference and use printf(input).
  34.  
  35. Unless he wanted:
  36.  
  37. putchar(*input);
  38.  
  39. -- 
  40. -----------------------------------------
  41. Lawrence Kirby | fred@genesis.demon.co.uk
  42. Wilts, England | 70734.126@compuserve.com
  43. -----------------------------------------
  44.